package com.yanqu.road.server.cmd.activity.langyabang;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.LangYaBangProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.langyabang.CrossLangYaBangMgr;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = CrossProtocol.C_LANG_YA_DECLARE_WAR,desc = "来跨服宣战")
public class CrosslangYaBangDeclareWarCmd extends CrossUnionCommand {

    private int activityId;
    private String unionUid;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        LangYaBangProto.InitiateDeclareWarReqMsg reqMsg = LangYaBangProto.InitiateDeclareWarReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        unionUid = reqMsg.getUnionId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        LangYaBangProto.InitiateDeclareWarRespMsg.Builder builder = CrossLangYaBangMgr.declareWar(activityId, packet.getPlayerId(), groupId, unionUid);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(GameProtocol.S_LANG_YA_DECLARE_WAR_RESULT_FROM_CROSS,builder);
        MessageHelper.sendPacket(serverId,packet.getPlayerId(),pbMsg);

    }

    @Override
    public void sendData() {

    }
}
